Refer to FIG. 1, which is a schematic diagram of an Android system architecture.
The first layer 101 is a Linux kernel drive layer, which is implemented by C/C++. Android core system services depend on the Linux kernel, including security, memory management, process management, network protocols, drive models, and the like. The Linux kernel is also used as an abstraction layer between hardware and a software stack. In addition to a standard Linux kernel, kernel drivers such as a Binder (IPC) driver, a camera driver and a power supply management driver are added in the Android system.
The second layer is a component library layer and a virtual machine layer. 102 is a component library layer (Libraries), and 103 is a virtual machine layer (Android Runtime). The component library layer 102 is implemented by C/C++, including a C/C++ library, which is available to different components in the Android system. They provide services for a developer by an Android application framework. As a run environment of the Android system, the virtual machine layer 103 provides most functions of a Java programming language core library, and consists of a Dalvik Java virtual machine and a basic Java class library.
The third layer 104 is an application framework layer. In the Android system, the developer can fully access an API (Application Programming Interface, application programming interface) framework used by core applications.
The fourth layer 105 is an application layer (Applications) layer. All Android applications are compiled in a Java language. An Android application developed by a user and an Android core application are on the same layer, and are all constructed based on an Android system API.
Currently, multitudinous electronic devices use the Android system, and a flash is installed on hardware of the devices. In most circumstances, the user has a need to use the flash. Therefore, how to control the flash in the Android system is a question under research by a person skilled in the art.
On the one hand, with development of optical communication, more electronic devices perform optical communication by a flash. In the Android system, the user exercises control, for example, on the application layer, and sends data by means of optical communication by the flash. In this case, the data is to-be-sent data. According to a corresponding encoding rule, the data is converted into time data that controls on and off states of the flash. That is, time data that controls on and off states of the flash is generated on the application layer. However, after the application layer obtains an instruction of controlling the flash, instructions of invoking a flash driver are sent one by one. After executing one instruction, the flash driver waits for a next instruction sent by the application layer. The instruction transmitted from the application layer to the driver layer needs to pass through layers such as the application framework layer, the component library layer, and the virtual machine layer. In this process, a delay is inevitable, and affects accuracy of data transmission in the optical communication process.
In the optical communication, visible light communication is generally applied. Visible light is applicable to both data transmission and illumination. However, due to the delay problem, a transmission speed (a flashing frequency of the visible light) needs to be restricted properly to ensure data accuracy in the data transmission process. Therefore, applicability is not good when the data needs to be transmitted at a high speed.
On the other hand, to control the on or off state of the flash in the Android system, a camera driver is generally invoked first, an inherent interface of a camera is used, and parameters of the camera are set to turn on or off the flash. This manner of controlling the flash is indirect control, and suffers a specific delay when the flash is invoked.